import { OPER } from '../../store'; 
import React from 'react';
import { Form, Button, Popconfirm, message } from 'antd';
import {
   DeleteOutlined,
} from '@ant-design/icons';

const useDelete = ({ url = '', data = {}, success = null, keys = [] }) => {
    const handleDel = () => {
       // 请求..
       message.success('删除成功');
       success && success();
    };
 
    const DeleteEle = (
       <React.Fragment>
          {OPER.isDelete && (
             <Form.Item key="delete">
                {keys.length === 0 ? (
                   <Button icon={<DeleteOutlined />} size="small" disabled>
                      批量删除
                   </Button>
                ) : (
                   <Popconfirm
                      title="批量删除"
                      description="你确定要删除吗？"
                      okText="确定"
                      cancelText="取消"
                      onConfirm={handleDel}
                   >
                      <Button
                         type="primary"
                         danger
                         icon={<DeleteOutlined />}
                         size="small"
                      >
                         批量删除
                      </Button>
                   </Popconfirm>
                )}
             </Form.Item>
          )}
       </React.Fragment>
    );
 
    return [DeleteEle];
 };

 export default useDelete